#include "gEnemy.h"

void gEnemy::initEnemy(gShip* a_player)
{
	m_wander = 0;
	m_player = a_player;
}

void gEnemy::input()
{
	if(m_trn.distance(m_player->getPos()) < getRad()*10.0f)
	{
		V2DF posA(getPos().x,getPos().z);
		V2DF velA(getVel().x,getVel().z);
		V2DF posB(m_player->getPos().x,m_player->getPos().z);
		V2DF velB(m_player->getVel().x,m_player->getVel().z);
		V2DF frc(seek(posA,velA,posB,m_phyObj->getMaxSpeed()));

		m_phyObj->addVelocity(frc.x,0,frc.y);
	}
	else
	{
		V2DF posA(getPos().x,getPos().z);
		V2DF velA(getVel().x,getVel().z);
		V2DF frc(wander(posA,velA,m_wander,m_phyObj->getMaxSpeed()));
		m_phyObj->addVelocity(frc.x,0,frc.y);
	}

	gShip::input();
}